package com.example.eurekaclient_consumer1.domain;

import java.util.HashMap;
import java.util.Map;

public class R extends HashMap {

    public static R ok(){
        R r = new R();
        r.put("code",0);
        r.put("msg","操作成功...");
        r.put("consumer","8001");
        return r;
    }

    public static R ok(Integer code){
        R r = new R();
        r.put("code",code);
        r.put("msg","操作成功...");
        return r;
    }

    public static R ok(Integer code,String msg){
        R r = new R();
        r.put("code",code);
        r.put("msg",msg);
        return r;
    }

    public static <T> R ok(Integer code,String msg,T data){
        R r = new R();
        r.put("code",code);
        r.put("msg",msg);
        r.put("data",data);
        return r;
    }

    public static R ok(Map<String,Object> map){
        R r = new R();
        r.putAll(map);
        return r;
    }

    public static R err(String msg){
        R r = new R();
        r.put("code",1);
        r.put("msg",msg);
        return r;
    }

    public static R err(Integer code,String msg){
        R r = new R();
        r.put("code",code);
        r.put("msg",msg);
        return r;
    }
}
